/*FILE UPDATE INFO**************************************************************
 * Author   : PURESUN
 * Update   : 2023-02-25
 * Info     : PURESUN public type library
 * Version  : 1.0.0
 ******************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __PURESUN_TYPE_H__
#define __PURESUN_TYPE_H__

/* Includes ------------------------------------------------------------------*/
#include "bsp_func_conf.h"
#ifndef __BSP_FUNC_CONF_H__
#include "bsp_func_conf_template.h"
#endif
#include "stdint.h"
#if (ENABLE_BOOL_STD)
#include "stdbool.h"
#endif

/* Exported macro ------------------------------------------------------------*/

/* Exported typedef -----------------------------------------------------------*/
typedef struct
{
    unsigned char group;
    unsigned char id;
} Timer_t;

/* Exported types ------------------------------------------------------------*/
typedef enum
{
    DISABLE = 0,
    ENABLE = !DISABLE
} FunctionalState;

#ifdef ENABLE_BOOL
typedef enum boolType
{
    b_false = 0,
    b_true = 1
} bool_t;
#endif

#ifndef NULL
#define NULL ((void *)0)
#endif // NULL

#if (ENABLE_C_STRING)
typedef char *string;
#endif // ENABLE_C_STRING

#ifdef ENABLE_INT8
typedef signed char int8_t;
typedef unsigned char uint8_t;
#endif // ENABLE_UINT8TYPE

#ifdef ENABLE_BYTE
typedef unsigned char byte;
#endif // ENABLE_BYTE

#ifndef CONFIG_IDF_TARGET // Prevent ESP32 IDF conflict

#if (ENABLE_INT16)
#ifndef _INT16_T_DECLARED
#define _INT16_T_DECLARED
typedef signed int int16_t;
#endif // _INT16_T_DECLARED
#ifndef _UINT16_T_DECLARED
#define _UINT16_T_DECLARED
typedef unsigned int uint16_t;
#endif // _UINT16_T_DECLARED
#endif // ENABLE_INT16

#if (ENABLE_INT32)
#ifndef _INT32_T_DECLARED
#define _INT32_T_DECLARED
typedef signed long int32_t;
#endif // _INT32_T_DECLARED
#ifndef _UINT32_T_DECLARED
#define _UINT32_T_DECLARED
typedef unsigned long uint32_t;
#endif // _UINT32_T_DECLARED
#endif // ENABLE_INT32

#if (ENABLE_INT64)
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#endif // ENABLE_INT32

#endif // CONFIG_IDF_TARGET Prevent ESP32 IDF conflict

typedef uint16_t word;
typedef unsigned char Status;
typedef unsigned char Device_Type_t;
typedef unsigned char bcd8_t;
typedef uint16_t bcd16_t;
typedef unsigned long bcd32_t;
typedef uint16_t width_t;
typedef uint16_t height_t;
typedef unsigned long address_t;
typedef unsigned char i2c_address_t;

#if (!defined(__SIZE_TYPE__) && !defined(__size_t))
#define __SIZE_TYPE__ 1
#define __size_t 1
typedef uint32_t size_t;
#endif // __SIZE_TYPE__

// For screen
typedef struct
{
    width_t width;
    height_t height;
} img_size_t;

typedef struct
{
    uint8_t x;
    uint8_t y;
} font_size_t, icon_size_t;

typedef struct
{
    byte uint;
    uint16_t x;
    uint16_t y;
} img_resolution_t;

typedef struct
{
    width_t width;
    height_t height;
} screen_size_t;

typedef struct
{
    uint16_t x;
    uint16_t y;
} position_t;

typedef struct
{
    img_size_t size;
    byte *data;
} image_t;

typedef uint16_t RGB16_t;

#pragma pack(1)
typedef struct
{
    uint8_t r;
    uint8_t g;
    uint8_t b;
} RGB24_t;
#pragma pack()

typedef struct
{
    uint8_t r;
    uint8_t g;
    uint8_t b;
    uint8_t a;
} RGBA32_t;

typedef struct
{
    uint8_t Y;
    uint8_t Cb;
    uint8_t Cr;
} YCrCb_t;

typedef RGB24_t RGB18_t;

typedef struct
{
    font_size_t size;
    struct
    {
        char *_char;
        const byte *_data;
    } font[128];
} font_24x14_t;

typedef struct
{
    icon_size_t size;
    struct
    {
        char *_name;
        const byte *_data;
    } icon[16];
} icon_24x28_t;

/* Exported constants --------------------------------------------------------*/
typedef enum
{
    c565_black = 0x0000,
    c565_red = 0xF800,
    c565_green = 0x07E0,
    c565_yellow = 0xFFE0,
    c565_blue = 0x001F,
    c565_navy = 0x000F,
    c565_dgreen = 0x03E0,
    c565_dcyan = 0x03EF,
    c565_maroon = 0x7800,
    c565_purple = 0x780F,
    c565_olive = 0x7BE0,
    c565_lgray = 0xC618,
    c565_dgray = 0x7BEF,
    c565_cyan = 0x07FF,
    c565_magenta = 0xF81F,
    c565_white = 0xFFFF
} Color_565_t;

/* Exported variables --------------------------------------------------------*/

/* Exported functions --------------------------------------------------------*/

#endif
/************************ (C) COPYRIGHT PURESUN *****END OF FILE***************/
